<?php
namespace App\Controllers;
use App\Requests\PayRequest;
use App\Services\PayService;
use Framework\BaseController;
use Illuminate\Support\Facades\Log;

class PayController extends BaseController
{


    /**  支付
     * @param PayRequest $request
     * @param PayService $service
     */
    public function pay(PayRequest $request, PayService $service)
    {
        $user_id = $this->getAuthId();
        $member_id = $request ->member_id();
        $type = $request ->type();
        $res = $service->pay($user_id, $member_id,$type);
        return $this->retSuccess($res);
    }


    /**支付宝回调
     * @param PayService $service
     */
    public function alipayNotify(PayService $service)
    {

        $data = app('alipay')->verify();
        Log::debug('Alipay notify', $data->all());
        $service->alipayNotify();
    }


    /**微信支付回调
     * @param PayService $service
     * @return mixed
     */
    public function wechatNotify(PayService $service)
    {

        $data = app('wechat_pay')->verify();
        Log::debug('Wechat notify', $data->all());
        $service->wechatNotify();

    }



}
